/*
 * Copyright (c) 2025 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef HMFS_ENCODING_H
#define HMFS_ENCODING_H

#include <string>
#include <functional>
#include <memory>
#include "hmfs_define.h"
#include "hmfs_utils.h"

namespace OHOS {
namespace Hmfs {
#define HMFS_HASH_COL_BIT    ((0x1ULL) << 63)
struct EncodingInfo {
    std::string encodingName;
    uint16_t encodingKey;
    uint16_t initialFlags;
};

bool IsNeedEncoding(int32_t encoding);
int32_t CaseFold(const unsigned char *str, size_t len, unsigned char *dest, size_t dlen);

const char *Utf8ToWchar(const char *input, wchar_t *wc, size_t insize);
const uint16_t *Utf16ToWchar(const uint16_t *input, wchar_t *wc, size_t insize);
uint16_t *WcharToUtf16(uint16_t *output, wchar_t wc, size_t outsize);
int Utf8ToUtf16(uint16_t *output, const char *input, size_t outsize, size_t insize);
char *WcharToUtf8(char *output, wchar_t wc, size_t outsize);
int Utf16Toutf8(char *output, const uint16_t *input, size_t outsize, size_t insize);
int32_t EncodingStrToValue(std::string& encodingString, uint16_t& value);
int32_t EncodingValueToStr(const uint16_t encodingVal, std::string& str);
uint16_t GetDefaultEncodingFlag(uint16_t encoding);
int32_t EncodingFlagStrToValue(std::string& flagsStr, uint16_t& flags);

} // namespace Hmfs
} // namespace OHOS
#endif // HMFS_ENCODING_H